package cn.com.nes.site.entity.em;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 系统用户职务类型 枚举
 *  值域对应 t_param 表 param_type=96
 */
public enum UserTypeEnum {

    _01("01", "维修"),
    _02("02", "安装"),
    _03("03", "财务"),
    _04("04", "管理"),
    _05("05", "客服"),
    _06("06", "技术售前"),
    _07("07", "内勤"),
    _08("08", "安装维修"),
    _09("09", "商城客服"),
    ;

    private String key;

    private String value;

    UserTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getVal(String key) {
        Map<String, String> map = new HashMap<>();
        for (UserTypeEnum value : values()) {
            map.put(value.getKey(), value.getValue());
        }
        return map.get(String.valueOf(key));
    }

    public static UserTypeEnum getEnum(String key) {
        Map<String, UserTypeEnum> map = new HashMap<>();
        for (UserTypeEnum userTypeEnum : values()) {
            map.put(userTypeEnum.getKey(), userTypeEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的用户职务");
        }
        return map.get(String.valueOf(key));
    }

}
